package com.ccxe.io;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.WritableComparable;

public class DataPair implements WritableComparable<DataPair>,Cloneable {

	private IntWritable day;
	private Text text;


	public DataPair(){
		set(new IntWritable(),new Text());
	}
	public DataPair(int i, String text) {
		set(new IntWritable(i),new Text(text));
	}
	public DataPair(int i, Text text) {
		set(new IntWritable(i),text);
	}
	public DataPair(long i, Text text) {
		set(new IntWritable((int)i),text);
	}
	public DataPair(IntWritable iw , Text text) {
		set(iw,text);
	}
	
	public void set(IntWritable day, Text text) {
		this.day = day;
		this.text = text;
	}

	@Override
	public void readFields(DataInput in) throws IOException {
		day.readFields(in);
		text.readFields(in);
	}

	@Override
	public void write(DataOutput out) throws IOException {
		day.write(out);
		text.write(out);
	}

	@Override
	public int compareTo(DataPair that) {
		return this.compareTo(that);
	}

	public IntWritable getDay() {
		return day;
	}

	public void setDay(IntWritable day) {
		this.day = day;
	}

	public Text getText() {
		return text;
	}

	public void setText(Text text) {
		this.text = text;
	}


}
